Install Drupal Memcached on a Media Temple DV Server
Site performance is crucial to a good user experience, and also is a factor in SEO. Because Drupal sites can be very query heavy at times, their performance can suffer. Luckily, there are a few caching libraries than can solve this problem and help increase performance. In this tutorial we’re going to install the Memcached library on a Media Temple DV Server, as well as configure the Memcache API and Integration module.
Memcached is described as a…
Free & open source, high-performance, distributed memory object caching system , generic in nature, but intended for use in speeding up dynamic web applications by alleviating database load.
Memcached is an in-memory key-value store for small chunks of arbitrary data (strings, objects) from results of database calls, API calls, or page rendering.
Backup Your Server
Full disclosure, I’m not a server guy. I know basic server configuration settings, and how to navigate the server through the command line. The next steps worked for me, but becuase I’m not a server expert, I recommend you make a full backup of your server before you continue on with this tutorial.
Install Memcached on a Media Temple DV Server
If you’re like me, you probably searched “How to install Memcached on a Media Temple DV Server” and found several results. Unfortunately for me, none of them worked. Again, I’m not a server guy, so I can’t blame the authors as they did provided very details instructions. It was just that I ran into issues where I couldn’t install a certain library, or copy a directory because of they way my server is set up.
Finally, after a lot of searching I stumped upon nLightened Development’s excellent post titled Installing APC Memcached and Varnish on Media Temple DV Level 4 Centos 6.5. I want to give the author(s) of that post full credit for the commands I used to install Memcached on a Media Temple DV Server.
- The first you will need to do is enable root access on your Media Temple DV server.
- Next, you need to ssh into your server. To do that, run
ssh root@yourdomain.com
- You’ll be prompted for your password with something like
root@yourdomain.com's password:
. You will not see your password being entered when you type it, so it’s helpful to copy and paste. Hit enter. - Once logged in enter
cd ~
to ensure you’re in the home directory. -
Finally, run the following commands. Again, this is from nLightened Development’s excellent post titled Installing APC Memcached and Varnish on Media Temple DV Level 4 Centos 6.5
- Confirm memcache is installed by running
telnet localhost 11211
-
You should get something similar to the following
- Then run the following
stats
-
If everything is setup correctly, you’ll get an output similar to the following
Edit php.ini
Now that memcached is installed on your server, you’ll need to edit your domain specific php.ini file. Since we’re dealing with a Media Temple DV, you can simply follow these steps to edit your domain specific php.ini file.
-
Once on the PHP Settings page, scroll to the Additional directives section and add the following lines.
If this doesn’t work, you might need to also edited you global php.ini file, but I don’t believe this is necessary.
-
Then add the following
-
Finally, restart the server by running
/etc/init.d/httpd restart
Install and Enable the Drupal Memcache API and Integration Module
- Put your site in maintenance mode by going to admin/config/development/maintenance
-
Install and enable Memcache API and Integration
Edit Drupal’s settings.php
-
Add the following to your settings.php file
-
Take your site back online by going to admin/config/development/maintenance